package tr.edu.metu.is550.isell.rest.resource;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import tr.edu.metu.is550.isell.service.MyBean;
import tr.edu.metu.is550.isell.service.MyBeanItem;
import tr.edu.metu.is550.isell.service.TestBean;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

@Component
@Path("test")
public class TestResource {

    @Autowired
    private TestBean testBean;

    @GET
    @Path("/hello")
    @Produces({MediaType.APPLICATION_JSON, MediaType.TEXT_PLAIN})
    public Response savePayment() {

        String result = testBean.sayHello();

        MyBean myBean = new MyBean("ilker", "celik");
        myBean.addItem(new MyBeanItem("ankara", "Turkey"));
        myBean.addItem(new MyBeanItem("izmir", "Turkey"));
        return Response.status(200).entity(myBean).build();

    }
}
